import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import Home from "../views/Home";
import TruckMana from "../views/truck/TruckMana";
import TruckTeamMana from "../views/truck/TruckTeamMana";
import CapacitySearch from "../views/capacity/CapacitySearch";
import HistoryTask from "../views/capacity/HistoryTask";
import ReceiveCarrierOrder from "../views/carrier/ReceiveCarrierOrder";
import WriteCarrierOrder from "../views/carrier/WriteCarrierOrder";
import TruckTeamCost from "../views/cost/TruckTeamCost";
import TruckTeamCostAccounting from "../views/cost/TruckTeamCostAccounting";
import DriverMana from "../views/drivers/DriverMana";
import ScheduleTask from "../views/scheduling/ScheduleTask";
import LogMana from "../views/sys/LogMana";
import SysMana from "../views/sys/SysMana";
import UserMan from "../views/sys/UserMan";

Vue.use(VueRouter)

/*数组 可定义多个*/
const routes = [

  {
    path: '/',    /*表示是 “ / ”  就展示Login页面*/
    name: 'login',
    component: Login,
    hidden:true
  }, {
    path: '/home',
    name: '车辆管理',
    component: Home,
    meta: {    /*meta:{}  指定可访问的用户角色*/
      role: ['运输管理员']
    },
    children: [
      {
        path: '/truckmana',
        name: '车辆管理',
        component: TruckMana
      }, {
        path: '/truckteammana',
        name: '车队管理',
        component: TruckTeamMana
      }
    ]
  }, {
    path: '/home',
    name: '驾驶员管理',
    component: Home,
    meta: {
      role: ['运输管理员']
    },
    children: [
      {
        path: '/drivermana',
        name: '驾驶员管理',
        component: DriverMana
      }
    ]
  }, {
    path: '/home',
    name: '运力查询',
    component: Home,
    meta: {
      role: ['调度员']
    },
    children: [
      {
        path: '/capacitysearch',
        name: '运力查询',
        component: CapacitySearch
      }, {
        path: '/historytask',
        name: '历史承运单',
        component: HistoryTask
      }
    ]
  }, {
    path: '/home',
    name: '任务调度',
    component: Home,
    meta: {
      role: ['调度员']
    },
    children: [
      {
        path: '/scheduletask',
        name: '调度承运任务',
        component: ScheduleTask
      }
    ]
  }, {
    path: '/home',
    name: '承运任务管理',
    component: Home,
    meta: {
      role: ['承运业务员']
    },
    children: [
      {
        path: '/writecarrierorder',
        name: '运单开出',
        component: WriteCarrierOrder
      }, {
        path: '/receivecarrierorder',
        name: '接收运单',
        component: ReceiveCarrierOrder
      }
    ]
  }, {
    path: '/home',
    name: '运输成本核算',
    component: Home,
    meta: {
      role: ['财务人员']
    },
    children: [
      {
        path: '/truckteamcostaccounting',
        name: '运输成本维护',
        component: TruckTeamCostAccounting
      }, {
        path: '/truckteamcost',
        name: '运输成本核算',
        component: TruckTeamCost
      }
    ]
  }, {
    path: '/home',
    name: '系统管理',
    component: Home,
    meta: {
      role: ['系统管理员']
    },
    children: [
      {
        path: '/userman',
        name: '用户管理',
        component: UserMan
      }, {
        path: '/logmana',
        name: '日志管理',
        component: LogMana
      }, {
        path: '/sysmana',
        name: '系统管理',
        component: SysMana
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
